<?php
/**
 * Created by PhpStorm.
 * User: yuguozhen
 * Date: 16/7/22
 * Time: 下午5:07
 */
namespace models\Timer\Insert;
class StatisticsModel extends \models\StatisticsDataResultModel{
    /**
     * 添加新的统计数据
     * @param $vaule 数量
     * @param $prev_start 统计时间
     */
    public function toInsert($prev_start,$vaule,$name,$type=1){
        $data = array(
            'STATISTICS_TYPE' => $type,  //1-新增，2-累计值
            'STATISTICS_VARIABLE_ID' => 0,
            'STATISTICS_VARIABLE_NAME' => $name,
            'STATISTICS_VALUE' => $vaule,
            'STATISTICS_DATE' => $prev_start,
            'CREATE_TIME' => date("Y-m-d H:i:s",$this->time),
            'UPDATE_TIME' => date("Y-m-d H:i:s",$this->time),
            'VALID_FLAG' => 'ENABLE',
        );
        $Ids = $this->insertGetId($data);
        if($Ids && $Ids>0){
            return true;
        }else{
            return false;
        }
    }
}